<?php

// +----------------------------------------------------------------------
// | 插件函数库
// +----------------------------------------------------------------------
// | author: Kai <maifakai@126.com>
// +----------------------------------------------------------------------


/**
* 格式化发送状态
* @author: Kai <maifakai@126.com>
* @param int $code 发送状态
* @param boolean $is_style 是否带样式输出
* @return string
*/
function format_send_status($code, $is_style = false)
{
    $status_arr = [
        '0' => '发送中',
        '1' => '发送成功',
        '2' => '发送失败',
        '3' => '发送超时'
    ];
    if ($is_style){
        $style = '';
        $i = '';
        switch ($code){
            case '0':
                $style = 'btn btn-default btn-xs';
                $i = '<i class="fa fa-hourglass-start" style="margin-right:3px;"></i>';
                break;
            case '1':
                $style = 'btn btn-success btn-xs';
                $i = '<i class="fa fa-check" style="margin-right:3px;"></i>';
                break;
            case '2':
                $style = 'btn btn-warning btn-xs';
                $i = '<i class="fa fa-close" style="margin-right:3px;"></i>';
                break;
            case '3':
                $style = 'btn btn-danger btn-xs';
                $i = '<i class="fa fa-clock-o" style="margin-right:3px;"></i>';
                break;
            default:
        }
        return '<span class="'.$style.'">'.$i.$status_arr[$code].'</span>';
    }
    return $status_arr[$code];
}